home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / mcomm600.zip / SUPLMNT.DOC < prev    next >
Text File  |  1994-10-03  |  39KB  |  888 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.          ===============================================================
  7.  
  8.                           MCOMM SUPPLEMENTAL FUNCTIONS
  9.                   Mike Dumdei, 6 Holly Lane, Texarkana TX 75503
  10.  
  11.          ===============================================================
  12.  
  13.          The functions described in this document are non-async related
  14.          functions provided as part of the MCOMM library.  MCOMM is
  15.          first and foremost a serial I/O library, therefore, much more
  16.          effort went into describing the use of the async functions than
  17.          you will find here.  Also, because MCOMM is a serial library,
  18.          most of the supplemental functions are targeted towards commun-
  19.          ications programs.  The video functions correctly handle all
  20.          ANSI sequences commonly used by BBS systems.  They also support
  21.          windowed output, allowing you to limit the area of the screen
  22.          that will be written to.  For example, you can reserve the
  23.          bottom line of the screen for a status line and no writes, ANSI
  24.          clear screen commands, etc., will be allowed to overwrite or
  25.          erase it.
  26.  
  27.             ANSI sequences supported are:
  28.                CUP - cursor position
  29.                HVP - horizontal, vertical position
  30.                CUU - cursor up
  31.                CUD - cursor down
  32.                CUF - cursor forward
  33.                CUB - cursor backward
  34.                SCP - save cursor position
  35.                RCP - restore cursor position
  36.                ED  - erase display
  37.                EL  - erase line
  38.                SGR - set graphics rendition (colors)
  39.                FF  - form feed, not really ANSI, clears the screen
  40.  
  41.          Tabs, newlines, carriage returns, line feeds, backspace, the
  42.          bell character, etc. are supported also.  See the 'Global Video
  43.          Variables' section for information on options available for
  44.          handling control characters, scrolling, etc.
  45.  
  46.          In addition to the video routines, there are also timeout
  47.          functions, crc functions, string functions, a carrier watchdog
  48.          function, and several others.  On the following pages, the
  49.          video functions are listed first followed by the non-video type
  50.          functions.
  51.  
  52.          Distribution policy:
  53.             These functions are part of the MCOMM async library and may
  54.          not be distributed without the remaining MCOMM files.  No part
  55.          of the registered version may be distributed or used except as
  56.          stated in the license agreement.
  57.  
  58.  
  59.  
  60.  
  61.          GLOBAL VIDEO VARIABLES:
  62.  
  63.          v_seg - segment  address of video RAM, set by initvid()
  64.          v_mode - current video mode, set by initvid()
  65.          v_page - current video page, set by initvid()
  66.          v_color - attribute to use when displaying chars, this variable
  67.             is set directly by ANSI sequences that change the displayed
  68.             attribute and can be set from your C program to change the
  69.             current attribute (def = 7)
  70.          v_snow - snow flag, if 1 chars are written to screen during
  71.             vertical retrace, if 0 chars are written without waiting for
  72.             retrace
  73.          v_cga - a CGA video system was detected
  74.          v_bios - BIOS video flag, if 1 screen writes are performed
  75.             using BIOS INT 10, if 0 screen writes are done directly to
  76.             video RAM
  77.          v_wndsz - current window borders, set by SETWND macro
  78.             (def = 0,0,24,79)
  79.          v_btmrgt, v_rgt, v_btm, v_toplft, v_lft, v_top -
  80.             v_wndsz individual components
  81.          vs_wndsz - limits for d_msgat(), d_nchat(), & d_atrbat()
  82.          vs_btmrgt, vs_toplft  - vs_wndsz individual components
  83.          v_scrlm - scroll mode, if 1 then the window is scrolled when
  84.             the cursor would move off the bottom (def), if 0 the cursor
  85.             wraps back to the top, if -1 cursor does not wrap to next
  86.             line until LF displayed, if 2 cursor wraps lines without LFs
  87.             but does not scroll without an LF (-1 & 2 for VT100 support)
  88.          v_cntrlm - control char handling, if 1 then control chars per-
  89.             form control functions, if 0 control chars are displayed as
  90.             graphic characters (def = 1)
  91.          v_textm - text mode, if 1 newlines are translated to CR/LF
  92.             pairs, if 0 newlines are displayed as LFs (def=1)
  93.          v_ansi - ansi mode, if 1 ANSI sequences are recognized, if 0
  94.             ANSI sequences are not recognized (def = 1)
  95.          v_wrel - if 1 cursor location arguments for functions that are
  96.             limited to the current window are relative to the top left
  97.             of the current window, if 0 cursor locations are absolute
  98.             (def = 0)
  99.          vs_wrel - if 1 cursor location arguments for functions that are
  100.             NOT limited to the current window are relative to the top
  101.             left of the current window, if 0 cursor locations are
  102.             absolute (def = 0)
  103.          v_ansiseq - shows that an ANSI sequence is currently in process
  104.             -- an ESC has been received by the display functions but the
  105.             terminating alpha character has not yet been received. (EX:
  106.             \33[0;36m is an ANSI sequence.  'v_ansiseq' is set to some
  107.             positive value when the ESC character is received and stay
  108.             positive until the sequence terminator is received.  When
  109.             the terminator is received, 'v_ansiseq' is set to a negative
  110.             value.  If the next character displayed after the terminator
  111.             is not the start of another ANSI sequence, 'v_ansiseq' is
  112.             reset to 0 after displaying that character.  This variable
  113.             is useful when stripping ANSI sequences from an incoming
  114.             stream of characters or when it is necessary to interrupt an
  115.             inprocess ANSI sequence.
  116.          v_bksp - if 1, backspace is destructive, if 0 backspace is not
  117.             destructive (def = 1)
  118.  
  119.  
  120.  
  121.  
  122.  
  123.          HANDLING OF UNSUPPORTED ANSI SEQUENCES:  (vers 5.52 change)
  124.  
  125.          When an unsupported ANSI sequence is displayed, the function
  126.          "x_ansi" is called. A default version of "x_ansi" that displays
  127.          the unrecognized sequence is included in the libraries.  To
  128.          override the default handler with one of your own, simply
  129.          put an "x_ansi" function in your code.  Your function will be
  130.          passed a pointer to any unrecognized ANSI sequences.   The
  131.          function prototype has the following form:
  132.  
  133.              void x_ansi(char *ansi_str);
  134.  
  135.          See TXZM.C for an example of function that overrides the
  136.          default "x_ansi" handler.
  137.  
  138.  
  139.          INTERRUPTING INPROCESS ANSI SEQUENCES:
  140.  
  141.          This section suggests some possible methods for handling the
  142.          situation where an ANSI sequence is in progress and it is nec-
  143.          essary to display characters that are not part of the sequence
  144.          and then resume the sequence.  An example of where this situa-
  145.          tion is a terminal program that is displaying incoming data
  146.          containing ANSI codes and the user of the program presses a key
  147.          that requires screen output in the middle of one of those
  148.          codes:
  149.                 Incoming data:    ESC[0;  (beginning of ANSI code)
  150.                 User keypress:     F1     (user wants a help screen)
  151.                 More incoming:    36m     (completion of ANSI code)
  152.  
  153.          The ANSI handler in the video library sees this:
  154.                   ESC[0;+----------------+
  155.                         |  Help Screen   |
  156.                         +----------------+36m
  157.          and since it doesn't know what to to with an ANSI code that
  158.          looks like that you see a small back arrow (for unrecognized
  159.          ANSI code), the help screen, and a 36m.
  160.  
  161.          To avoid this problem, you can do one of three things.  The
  162.          first is you can ignore the local user input until the
  163.          inprocess ANSI sequence is completed.  The v_ansiseq variable
  164.          described previously can be used to test whether or not an ANSI
  165.          sequence is currently in process.  Example:
  166.             if (KBHIT()) {
  167.                while (v_ansiseq && ((ch = rx_timeout(1)) != TIMED_OUT))
  168.                   d_ch(ch);
  169.                proc_keypress();
  170.             }
  171.  
  172.          The second method is to use the 'd_msgat' function to display
  173.          local strings.  It automatically save the ANSI sequence status,
  174.          and the present cursor position before displaying the passed
  175.          string.  On exit, the current status of any inprocess ANSI
  176.          sequences and the cursor position are restored.  It will also
  177.          place strings outside the current window making it the best
  178.          function for updating the terminal status line and displaying
  179.          local screens and messages.
  180.  
  181.          The last option is to manually preserve the v_ansiseq variable,
  182.          display local messages, and then manually restore v_ansiseq:
  183.             temp = v_ansiseq, v_ansiseq = 0;
  184.             displayhelp();
  185.             v_ansiseq = temp;
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.          VIDEO MACROS:
  193.  
  194.          ---------------------------------------------------------------
  195.          SETWND(top, left, btm, rgt)  -- Set Window Dimensions
  196.          ---------------------------------------------------------------
  197.          This macro is used to set the global variable that defines the
  198.          screen area that will be affected by the majority of the video
  199.          functions.  Initially set to 0,0,24,79.
  200.  
  201.  
  202.          ---------------------------------------------------------------
  203.          SETTOPLFT(top, lft), SETBTMRGT(btm, rgt)
  204.          ---------------------------------------------------------------
  205.          Same as above but only sets one corner.
  206.  
  207.  
  208.          ---------------------------------------------------------------
  209.          SETsWND(top, left, btm, rgt) -- Set Screen Dimensions
  210.          ---------------------------------------------------------------
  211.          Sets the screen limits for the functions that are allowed to
  212.          write outside the current window.
  213.  
  214.  
  215.          ---------------------------------------------------------------
  216.          SETsTOPLFT(top, lft), SETsBTMRGT(btm, rgt)
  217.          ---------------------------------------------------------------
  218.          Same as SETsWND but for one corner only.
  219.  
  220.  
  221.          ---------------------------------------------------------------
  222.          SCRBUF(rows, cols)
  223.          ---------------------------------------------------------------
  224.          Returns a value that is the required buffer size for the
  225.          pu_scrnd and fpu_scrnd functions.  It is used like this:
  226.  
  227.            sbuf = malloc(SCRBUF(25,80));
  228.            if (sbuf != NULL)
  229.               pu_scrnd(0, 0, 25, 80);
  230.  
  231.  
  232.          ---------------------------------------------------------------
  233.          d_strnat(row,col,char,attrib,count)
  234.          ---------------------------------------------------------------
  235.          Macro for compatibility with older versions of ANSIDRV.
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.          VIDEO FUNCTIONS:
  243.  
  244.          ---------------------------------------------------------------
  245.          initvid -- Initializes Video Variables
  246.          ---------------------------------------------------------------
  247.             int initvid(void);
  248.  
  249.          Initializes the global video variables, v_seg, v_mode, v_page,
  250.          and v_snow.  You MUST call this function before using any of
  251.          the other video functions.  Calling 'initvid' does not
  252.          automatically cause the linker to pull in the code for the
  253.          remaining ANSI video routines.  Initvid only includes the
  254.          global variables and enough code to initialize those variables.
  255.  
  256.  
  257.          ---------------------------------------------------------------
  258.          loc -- Locate the Cursor
  259.          ---------------------------------------------------------------
  260.             void loc(int row, int col);
  261.  
  262.          Locates the cursor at row, col.  The top left of the screen is
  263.          0,0.  If an attempt is made to locate the cursor outside the
  264.          current window the cursor is placed on the window edge closest
  265.          to the passed location.  Setting the global variable 'v_wrel'
  266.          to a non-zero value will make location 0,0 be the top, left
  267.          corner of the current window.
  268.  
  269.  
  270.          ---------------------------------------------------------------
  271.          d_strat -- Display String At Specified Location
  272.          ---------------------------------------------------------------
  273.             void d_strat(int row, int col, char *string);
  274.  
  275.          This function displays a string at row, col.  The attribute
  276.          used is the current value of the global variable 'v_color'.
  277.          The area where the string can be displayed is limited to the
  278.          current window (set by SETWND).
  279.  
  280.  
  281.          ---------------------------------------------------------------
  282.          d_str  -- Display String At Current Location
  283.          ---------------------------------------------------------------
  284.             void d_str(char *string);
  285.  
  286.          Displays a string at the current cursor position using v_color
  287.          for the attribute.
  288.  
  289.  
  290.          ---------------------------------------------------------------
  291.          d_chat -- Display Char At Specified Location
  292.          ---------------------------------------------------------------
  293.             void d_chat(int row, int col, char ch);
  294.  
  295.          Displays one character at the specified position using v_color
  296.          for the attribute.
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.          ---------------------------------------------------------------
  304.          d_ch -- Display Char at Current Location
  305.          ---------------------------------------------------------------
  306.             void d_ch(char ch);
  307.  
  308.          Display one character at the present cursor position using
  309.          v_color for the attribute.
  310.  
  311.  
  312.          ---------------------------------------------------------------
  313.          d_msgat -- Display Message At Location
  314.          ---------------------------------------------------------------
  315.             void d_msgat(int row, int col, int atrib, char *str);
  316.  
  317.          Displays string at the specified location using the specified
  318.          attribute.  This routine is not limited to writing within the
  319.          current window.  It is limited by the variable set by the
  320.          SETsWND macro (s stands for screen).  The routine does not move
  321.          the cursor and does not break up in process ANSI sequences.
  322.          Used to display strings outside the current window.
  323.  
  324.  
  325.          ---------------------------------------------------------------
  326.          d_msgatd -- Display Message At Location Direct Write
  327.          ---------------------------------------------------------------
  328.             void d_msgatd(int row, int col, int atrib, char *str);
  329.  
  330.          This routine writes 'str' at the specified location using the
  331.          given attribute.  Unlike the previous function, this function
  332.          does not support ANSI or control characters.  It is for
  333.          displaying strings on the screen in the fastest possible
  334.          manner.  The 'v_bios' variable described in the list of global
  335.          variables does not apply to this function.  It always uses
  336.          direct screen writes.
  337.  
  338.  
  339.          ---------------------------------------------------------------
  340.          d_atrbat -- Display Attribute At Location With Count
  341.          ---------------------------------------------------------------
  342.             void d_atrbat(int row, int col, int atrb, int count);
  343.  
  344.          Resets the displayed attribute at the specified location to the
  345.          given attribute for the given number of locations.  This rout-
  346.          ine performs like d_msgat() in regard to window limitations,
  347.          cursor movement, and ANSI sequences.
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.          ---------------------------------------------------------------
  355.          d_nchat -- Display Char At Location With Count
  356.          ---------------------------------------------------------------
  357.             void d_nchat(char row, char col, char ch, char atrb,
  358.              int nbr, char dir);
  359.  
  360.          Displays 'ch', 'nbr' times, using 'atrb' for the attribute, at
  361.          'row, col'.  If 'dir' is 0 the chars are displayed vertically
  362.          otherwise they are displayed horizontally.  This routine
  363.          performs like d_msgat in regard to window limitations, cursor
  364.          movement, and ANSI sequences.
  365.  
  366.  
  367.          ---------------------------------------------------------------
  368.          pu_scrnd -- Move Specified Screen Region To A Buffer
  369.          ---------------------------------------------------------------
  370.             void pu_scrnd(int row, int col, int nrows, int ncols,
  371.              char *buf);
  372.  
  373.          This function saves a section of the video display beginning at
  374.          'row', 'col', that is 'nrows' high and 'ncols' wide.  It also
  375.          saves the current cursor position and shape.  The buffer to
  376.          hold the screen information must be (2 * nrows * ncols) + 16
  377.          bytes in size.  The 'v_bios' variable does not apply to this
  378.          function.  It operates in direct write mode only.
  379.  
  380.  
  381.          ---------------------------------------------------------------
  382.          po_scrnd -- Restore a Screen Saved by 'pu_scrnd' Function
  383.          ---------------------------------------------------------------
  384.             void po_scrnd(char *buf);
  385.  
  386.          Restores the screen and cursor information that was placed in
  387.          'buf' by a previous pu_scrnd call.  The 'v_bios' function does
  388.          not apply to this function.
  389.  
  390.  
  391.          ---------------------------------------------------------------
  392.          fpu_scrnd -- Move Specified Screen Region To A FAR Buffer
  393.          ---------------------------------------------------------------
  394.             void fpu_scrnd(int row, int col, int nrows, int ncols,
  395.              char _far *buf);
  396.  
  397.          Same as pu_scrnd except moves screen information to a FAR
  398.          buffer.
  399.  
  400.          ---------------------------------------------------------------
  401.          fpo_scrnd -- Restore a Screen Saved by 'fpu_scrnd' Function
  402.          ---------------------------------------------------------------
  403.             void fpo_scrnd(char _far *buf);
  404.  
  405.          Same as po_scrnd except restores data pushed by 'fpo_scrnd'.
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.          ---------------------------------------------------------------
  413.          pushscrn -- Move Specified Screen Region To A Buffer      ( C )
  414.          ---------------------------------------------------------------
  415.             int pushscrn(int row, int col, int nrows, int ncols);
  416.  
  417.          C function that utilizes pu_scrnd and malloc to build a last in
  418.          first out stack of up to 10 screens.  Performs the same as
  419.          pu_scrnd except automatically allocates the buffer space.
  420.          C source code is included for this function.  Returns 0 if
  421.          successful, non-zero if an attempt is made to push too many
  422.          screens or the call to malloc space for the screen data fails.
  423.  
  424.  
  425.          ---------------------------------------------------------------
  426.          popscrn -- Restore Last Screen Saved by 'pushscrn'        ( C )
  427.          ---------------------------------------------------------------
  428.             int popscrn(void);
  429.  
  430.          Restores last screen pushed by pushscrn function.  Returns 0 if
  431.          successful or non-zero if an attempt is made to pop a screen
  432.          when no more screens remain in the screen stack.
  433.  
  434.  
  435.          ---------------------------------------------------------------
  436.          fpushscrn -- Move Specified Screen Region To FAR Buffer   ( C )
  437.          ---------------------------------------------------------------
  438.             int fpushscrn(int row, int col, int nrows, int ncols);
  439.  
  440.          Same as pushscrn except the screen buffers are allocated from
  441.          far memory using your compiler's version of a far malloc
  442.          function.  (MSC _fmalloc, Turbo C = farmalloc).  Source code is
  443.          included if you are using a compiler that has a different name
  444.          for the function to do this.
  445.  
  446.  
  447.          ---------------------------------------------------------------
  448.          fpopscrn -- Restore Last Screen Saved by 'fpushscrn'      ( C )
  449.          ---------------------------------------------------------------
  450.             int fpopscrn(void);
  451.  
  452.          Same as popscrn except restores last screen pushed by
  453.          fpushscrn.
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.          ---------------------------------------------------------------
  461.          moveblk -- Move Screen To Buffer / Buffer To Screen
  462.          ---------------------------------------------------------------
  463.             void moveblk(int row, int col, int nrows, int ncols,
  464.              char *buf, int dirflag);
  465.  
  466.          This function does the same thing as pu_scrnd and po_scrnd
  467.          combined except it does not save data on the cursor position or
  468.          shape and all args are needed when both saving and restoring.
  469.          The 'dirflag' determines which direction the data is to be
  470.          moved.  If it is NZ, data is transferred from the screen to the
  471.          buffer.  If it is zero, then buffer data is transferred to the
  472.          screen.  The additional 16 bytes of buffer space required by
  473.          pu_scrnd are not required for this function since it does not
  474.          build the header for the screen region and cursor data.
  475.  
  476.  
  477.          ---------------------------------------------------------------
  478.          rd_scrn -- Read Attrib/Char At Cursor Position
  479.          ---------------------------------------------------------------
  480.             int rd_scrn(void);
  481.  
  482.          Reads the attribute and character at the current cursor pos-
  483.          ition.  The attribute is returned in the upper 8 bits of the
  484.          return value and the character in the lower 8 bits.
  485.  
  486.  
  487.          ---------------------------------------------------------------
  488.          rd_scrnd -- Read Screen String From Specified Location
  489.          ---------------------------------------------------------------
  490.             char *rd_scrnd(int row, int col, int nbytes, char *buf);
  491.  
  492.          Reads a string that is a maximum of 'nbytes' long beginning at
  493.          the specified location.  The string is stored in 'buf' and
  494.          trailing spaces are trimmed.  The 'v_bios' variable does not
  495.          apply to this function.  The return value is a pointer to
  496.          'buf'.
  497.  
  498.          ---------------------------------------------------------------
  499.          cls -- Clear Currently Defined Window
  500.          ---------------------------------------------------------------
  501.             void  cls(void);
  502.  
  503.          Clears the current window using v_color for the attribute.  Re-
  504.          turns nothing.
  505.  
  506.  
  507.          ---------------------------------------------------------------
  508.          scrlup -- Scroll Window Up
  509.          ---------------------------------------------------------------
  510.             void scrlup(int nbrlines);
  511.  
  512.          Scrolls the current window up the specified number of lines.
  513.          The attribute used for blank lines is 'v_color'.
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.          ---------------------------------------------------------------
  521.          scrldn -- Scroll Window Down
  522.          ---------------------------------------------------------------
  523.             void scrldn(int nbrlines);
  524.          Same as previous function except scrolls down.
  525.  
  526.  
  527.          ---------------------------------------------------------------
  528.          scrlupat -- Scroll Specified Area Up
  529.          ---------------------------------------------------------------
  530.             void scrlup(int top, int lft, int btm, int rgt, int nlines);
  531.  
  532.          Same as previous scrlup function except instead of using the
  533.          current window, it scrolls the specified area.
  534.  
  535.  
  536.          ---------------------------------------------------------------
  537.          scrldnat -- Scroll Specified Area Down
  538.          ---------------------------------------------------------------
  539.             void scrldn(int nbrlines);
  540.          Same as previous scrldn function except instead of using the
  541.          current window, it scrolls the specified area.
  542.  
  543.  
  544.          ---------------------------------------------------------------
  545.          setcurloc -- Set Cursor Location
  546.          ---------------------------------------------------------------
  547.             void setcurloc(int location);
  548.  
  549.          Similar to loc(), but this function passes the row and column
  550.          one variable with the upper 8 bits being the row and the lower
  551.          8 bits the column.  This function is used in conjunction with
  552.          getcurloc() to save and restore the cursor position.
  553.  
  554.  
  555.          ---------------------------------------------------------------
  556.          getcurloc -- Get Cursor Location
  557.          ---------------------------------------------------------------
  558.             int getcurloc(void);
  559.  
  560.          Returns the cursor location as an integer.  The upper 8 bits is
  561.          the row, and the lower 8 bits is the column.
  562.  
  563.  
  564.          ---------------------------------------------------------------
  565.          setcursiz -- Set Cursor Size
  566.          ---------------------------------------------------------------
  567.             void setcursiz(int);
  568.  
  569.          Sets the starting and ending scan lines for the cursor. The
  570.          upper 8 bits are the starting scan line and the lower 8 bits
  571.          are the ending scan line.
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.          ---------------------------------------------------------------
  579.          getcursiz -- Get Cursor Size
  580.          ---------------------------------------------------------------
  581.             int getcursiz(void);
  582.  
  583.          Returns the current starting and ending scan lines of the cur-
  584.          sor.  The high bits are the starting scan line and the lower 8
  585.          bits are the ending scan line.
  586.  
  587.  
  588.          ---------------------------------------------------------------
  589.          setvmode -- Set Video Mode
  590.          ---------------------------------------------------------------
  591.             void setvmode(int mode);
  592.  
  593.          Sets the video mode to 'mode'.  The only modes that these func-
  594.          tions will work in, however, are the 80 x 25 text modes.
  595.  
  596.  
  597.          ---------------------------------------------------------------
  598.          getvmode -- Get Video Mode
  599.          ---------------------------------------------------------------
  600.             int getvmode(void);
  601.  
  602.          Returns the current video mode.
  603.  
  604.  
  605.          ---------------------------------------------------------------
  606.          setvpage -- Set Video Page
  607.          ---------------------------------------------------------------
  608.             void setvpage(int page);
  609.  
  610.          Sets the video page to 'page'.  Pages are only supported on
  611.          color systems.  This function also modifies v_seg so that it
  612.          reflects the new page value set.
  613.  
  614.  
  615.          ---------------------------------------------------------------
  616.          getvpage -- Get Video Page
  617.          ---------------------------------------------------------------
  618.             int getvpage(void);
  619.  
  620.          Returns the current video page.
  621.  
  622.  
  623.          ---------------------------------------------------------------
  624.          setvbordr -- Set Video Border
  625.          ---------------------------------------------------------------
  626.             void setvbordr(int attrib);
  627.  
  628.          Sets the border color of the screen.
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.          MISCELLANEOUS FUNCTIONS:
  636.  
  637.          ---------------------------------------------------------------
  638.          str*just -- right, left, or center justify a string.
  639.          ---------------------------------------------------------------
  640.          These functions 1st trim all spaces (ASCII 32's) and then just-
  641.          ify the string in the specified field width using the specified
  642.          pad character.  The memory area where the string is located
  643.          must be at least field size + 1 in size.  If the string is
  644.          longer than the field width, strljust and strcentr truncate the
  645.          right portion of the string; strrjust will cut off the right
  646.          side.  Only ASCII 32's are trimmed.
  647.  
  648.          Returns a pointer to the justified string.
  649.  
  650.          char *strrjust(char *, int, char);
  651.          char *strljust(char *, int, char);
  652.          char *strcentr(char *, int, char);
  653.  
  654.          str_out = strrjust(str_in, fieldsz, padchar);
  655.  
  656.  
  657.          ---------------------------------------------------------------
  658.          str*trim -- trims spaces (ASCII 32's only) from a string.
  659.          ---------------------------------------------------------------
  660.          Trims spaces from left, right, or both ends of a string.
  661.  
  662.          Returns pointer to the passed string.
  663.  
  664.          char *strrtrim(char *);
  665.          char *strltrim(char *);
  666.          char *strtrim(char *);
  667.  
  668.          str_out = strrtrim(str_in);
  669.  
  670.  
  671.          ---------------------------------------------------------------
  672.          strsum -- strcat for multiple strings.
  673.          ---------------------------------------------------------------
  674.          Makes one string from multiple strings.  Unlike strcat, the
  675.          first string in the list is not one of the strings to add but
  676.          instead is a buffer for the result of adding the rest of the
  677.          strings in the list.  The args to the function are:
  678.             the dest, a variable number of char *'s, a NULL ptr
  679.  
  680.          Returns a pointer to the result string.
  681.  
  682.          char *strsum(char *, ...);
  683.  
  684.          str_out = strsum(str_out, str_in1, str_in2, ..., NULL);
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.          ---------------------------------------------------------------
  692.          strpbrkf -- finds 1st char in str1 not in str2.
  693.          ---------------------------------------------------------------
  694.          This function looks for the first character in 'str1' that does
  695.          not belong to the character set contained in 'str2' and returns
  696.          a pointer to that character.  If 'str1' consists entirely of
  697.          characters in 'str2', NULL is returned.  Opposite of strpbrk.
  698.  
  699.          char *strpbrkf(char *, char *);
  700.          rtnstr = strpbrkf(str1, str2);
  701.  
  702.  
  703.          ---------------------------------------------------------------
  704.          strrstr -- find last occurrence of str2 in str1.
  705.          ---------------------------------------------------------------
  706.          This function returns a pointer to the last occurrence of
  707.          'str2' within 'str1'.  If 'str2' is not in 'str1', NULL is
  708.          returned.  This is identical to the standard 'strstr' function
  709.          except it works from the end of 'str1' towards the beginning
  710.          instead of the other way.
  711.  
  712.          char *strrstr(char *, char *);
  713.          rtnstr = strrstr(str1, str2);
  714.  
  715.  
  716.          ---------------------------------------------------------------
  717.          strcntch -- returns number occurrences of char in string.
  718.          ---------------------------------------------------------------
  719.          int strcntchr(char *, char);
  720.          count = strcntchr(string, srchchar);
  721.  
  722.  
  723.          ---------------------------------------------------------------
  724.          calc_crc -- 16 bit CRC routine for block data.
  725.          ---------------------------------------------------------------
  726.          Calculates the CRC for a block of data 'count' bytes long.
  727.          Returns CRC.
  728.  
  729.          int calc_crc(char *, int);
  730.          crc = calc_crc(data, nbr_bytes_of_data);
  731.  
  732.  
  733.          ---------------------------------------------------------------
  734.          update_crc -- 16 bit CRC for character at a time data.
  735.          ---------------------------------------------------------------
  736.          Returns updated CRC.
  737.  
  738.          int update_crc(int, char);
  739.          crc = update_crc(crc, char);
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.          ---------------------------------------------------------------
  747.          watchdogset -- Enables/Disables watchdog function  (C function)
  748.          watchdoghook -- ASM function used by WATCHDOG.C
  749.          ---------------------------------------------------------------
  750.          int watchdogset(int flag, int combase)
  751.  
  752.          To enable:  call with flag = 1
  753.             combase = base adrs of comm chip (ex: 3F8)
  754.          To disable: call with flag = 0
  755.             combase = don't care
  756.  
  757.          This function monitors Carrier Detect on the selected serial
  758.          port and does a cold reboot if the carrier is lost.  If you use
  759.          both this function and the TIMEOUT functions make sure you
  760.          uninstall the hooks in the reverse order that you installed
  761.          them and make sure that you uninstall them before you exit your
  762.          program.  Failing to do this will cause your system to crash
  763.          (the redirected interrupt vectors are now pointing to freed
  764.          memory instead of a program).
  765.  
  766.  
  767.          ---------------------------------------------------------------
  768.          ctshookset -- Patch to BIOS INT14 to prevent timeouts when
  769.             using CTS handshaking  (C function)
  770.          int14ctshook -- ASM function used with CTSHOOKSET
  771.          ---------------------------------------------------------------
  772.          int ctshookset(int flag, int portval, int combase)
  773.          void interrupt far int14ctshook(void);
  774.  
  775.          To enable:  call with flag = 1
  776.             portval = COM1 (0) or COM2 (1)
  777.             combase = base adrs of comm chip (ex: 3F8)
  778.          To disable: call with flag = 0
  779.             portval = don't care
  780.             combase = don't care
  781.  
  782.          This function sets a hook into the BIOS serial interrupt vector
  783.          that waits indefinitely for CTS to go high on the specified
  784.          port when sending data.  All INT14 calls that are not for the
  785.          specified port and all service requests except for 'send byte'
  786.          are passed on to the old INT14 vector unaltered.  In other
  787.          words for the hook to have any effect when INT14 is called:
  788.             1)  DX has to equal the 'portval' you set here
  789.             2)  AH has to equal '1' -- the send char service ID
  790.          The effect it has then is to wait for CTS to be true then exe-
  791.          cute the old INT14 interrupt.  The purpose of the function is
  792.          keep high speed modems that CTS handshake from creating timeout
  793.          errors when redirecting stdout and stderr to the comm port.  Be
  794.          SURE to uninstall the hook before exiting your program or the
  795.          redirected interrupt vector will be pointing to free memory
  796.          instead of an interrupt handler.
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.          ---------------------------------------------------------------
  804.          tickhookset -- Enables/Disables 'ticker' for timer functions
  805.          ---------------------------------------------------------------
  806.          int tickhookset(int flag)
  807.  
  808.          To enable:  call with flag = 1
  809.          To disable: call with flag = 0
  810.  
  811.          This function enables the 'tick counter' used by the timeout
  812.          and tdelay functions by pointing the TIMER interrupt vector,
  813.          1Ch, to a new interrupt handler that increments the counter
  814.          approximately 18.2 times per second.  The advantage of using
  815.          this method over the BIOS function is no coding is needed to
  816.          account for the possibility of calling your timer functions
  817.          near midnight.  The 'tick counter' is a long and may be read by
  818.          calling 'get_ticker'.
  819.  
  820.          YOU MUST DISABLE 'TICKER' BEFORE EXITING YOUR PROGRAM.
  821.  
  822.  
  823.          ---------------------------------------------------------------
  824.          set_timeout     -- initializes a timer
  825.          set_longtimeout -- initialize a long timer
  826.          timed_out       -- checks if a timeout has occurred
  827.          ---------------------------------------------------------------
  828.          void set_timeout(long *t_out, unsigned ticks);
  829.  
  830.          int timed_out(long *t_out);
  831.  
  832.          These functions work in conjunction with each other and require
  833.          the 'tick counter' to be activated by TICKHOOKSET.  The fol-
  834.          lowing macros are defined in EXTRA.H:
  835.             SET_TO_TENTHS(to, tenths)  set_timeout((&to), (tenths)*9/5)
  836.             SET_TO_SECS(to, secs)      set_timeout((&to), (secs)*18)
  837.             SET_TO_MINS(to, mins)      set_timeout((&to), (mins)*1080)
  838.          After setting the timeout value with one of the above macros
  839.          you then call timed_out() see if a timeout has occurred.  Here
  840.          is an example:
  841.  
  842.             long to;
  843.             int toolong = 0;
  844.  
  845.             tickhookset(1);                      /* enable hook */
  846.             SET_TO_SECS(to, 2);       /* set timeout for 2 secs */
  847.             while (!(toolong = timed_out(&to)))
  848.             {
  849.                if (condition_met()) /* wait for cond 2 secs max */
  850.                   break;
  851.             }
  852.             if (toolong)             /* timed out if toolong NZ */
  853.                return TIMEOUT_ERR;
  854.  
  855.          Notice that the macro does not require the '&' operator but the
  856.          call to timed_out() does.  Using these functions, you may have
  857.          as many timeouts going as you have timeout variables.
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.          ---------------------------------------------------------------
  865.          get_ticker -- get the current value of internal tick counter
  866.          ---------------------------------------------------------------
  867.          long get_ticker(void);
  868.  
  869.          Returns the value of the internal tick counter.  This counter
  870.          is incremented 18.2 times a second from the time tickhookset(1)
  871.          is called until tickhookset(0) is called.
  872.  
  873.  
  874.          ---------------------------------------------------------------
  875.          tdelay -- kill time function
  876.          ---------------------------------------------------------------
  877.          int tdelay(unsigned ticks);
  878.  
  879.          This functions delays the specified number of ticks and then
  880.          returns.  Before using this function you must enable the
  881.          internal tick counter by calling 'tickhookset'.
  882.  
  883.          The following macros are defined in EXTRA.H:
  884.             DELAY_TENTHS(tenths)     tdelay(((tenths)*9/5)+1)
  885.             DELAY_SECS(secs)         tdelay((secs)*18)
  886.             DELAY_MINS(mins)         tdelay((mins)*1080)
  887.  
  888.